package codetype.controller;

import cn.hutool.core.collection.ListUtil;
import codetype.annotation.TranslateCode;
import codetype.bean.Test;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Controller
 *
 * @author zhanghui145
 * @date 2021/12/28 18:56
 * @since 1.0.0
 */
@RestController
public class TestController {

    static Test test = Test.builder().name("zhangsan").gender("1").age(20).build();
    static List<Test> testList = new ArrayList<>();
    static {
        Test test1 = Test.builder().name("lisi").gender("2").age(18).build();
        test.setTests(ListUtil.toList(test1));
        Test test2 = Test.builder().name("wangwu").gender("1").age(100).build();
        Test test3 = Test.builder().name("liuliu").gender("2").age(200).build();
        testList.add(test2);
        testList.add(test3);
    }

    @GetMapping("/test1")
    @TranslateCode
    public Test test() {
        return test;
    }

    @GetMapping("/test2")
    public Test test1() {
        return test;
    }

    @GetMapping("/test3")
    @TranslateCode
    public List<Test> test2() {
        return testList;
    }
}
